<template>
  <div>
    <!-- 资金返利对账表确认 -->
    <TopFilter :list="topFilterList" :cols="3" @filterChange="changeHandle" @onCollapse="collapseHandle" :labelWidth="110"></TopFilter>

    <FilterTable
      ref="table"
      columnsRef="qjhRebateStatementCommit"
      :isSelectColumn="false"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onColumnsChange="columns => (this.columns = columns)"
    >
      <template slot="controls" slot-scope="props">
        <el-button size="small" type="text" style="font-size:14px; font-weight:bold;margin-right:20px;">
          <span>下发后一周内未确认反馈，视为对账无问题</span>
        </el-button>
      </template>
    </FilterTable>

    <Drawer :visible.sync="visible" title="确认" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }" width="72%">
      <SonModel :rowData="formData" @close="emitCloseHandler" />
    </Drawer>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getRegion } from '@/api/omFinance';
import { exportExcelFile } from '@/utils/index';
import { queryList, exportExcel } from '@/api/dealerFinance/RebateManage/RebateStatementCommit';
import SonModel from './SonModel';

export default {
  name: 'RebateStatementCommit',
  mixins: [dictionary],

  data() {
    this.BaseTable = null;
    return {
      topFilterList: this.createdFrom(),
      columns: this.createdTable(),
      fetchParams: {
        searchType: 2
      },
      fetchApi: queryList,
      formData: {},
      isDealer: false,
      visible: false
    };
  },
  components: {
    SonModel
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  created() {},
  methods: {
    changeHandle(params) {
      this.fetchParams = Object.assign({}, this.fetchParams, params);
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },

    emitCloseHandler(val, type) {
      this.visible = val;

      if (type == 'refresh') {
        this.fetchParams = Object.assign({}, this.fetchParams);
      }
    },
    auditHandle(row) {
      this.visible = true;
      this.formData = row;
    },
    createdFrom() {
      return [
        {
          type: 'SELECT',
          label: '对账分类',
          fieldName: 'verifyType',
          placeholder: '请选择',
          itemList: this.createDictList('6086')
        },
        {
          type: 'RANGE_DATE',
          label: '下发日期',
          fieldName: 'issueBeginDate|issueEndDate',
          initialValue: [],
          dateType: 'exactdaterange'
        },
        {
          type: 'SELECT',
          label: '状态',
          fieldName: 'status',
          placeholder: '请选择',
          itemList: this.createDictList('6084').filter(x => x.value == 60841002 || x.value == 60841004)
        },
        {
          type: 'SELECT',
          label: '动力形式',
          fieldName: 'powerType',
          placeholder: '请选择',
          itemList: this.createDictList('6008')
        }
      ];
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 50,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <multiuse-button size="mini" type="text" onClick={() => this.auditHandle(props.row)}>
                  确认
                </multiuse-button>
              </div>
            );
          }
        },
        // {
        //   title: '事业部',
        //   dataIndex: 'deptName',
        //   sorter: true,
        //   filter: true,
        //   filterType: 'input'
        // },
        {
          title: '经销商代码',
          dataIndex: 'dealerCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '经销商名称',
          dataIndex: 'dealerName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '状态',
          dataIndex: 'status',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('6084').filter(x => x.value == 60841002 || x.value == 60841004),
          render: props => {
            return <span>{this.createDictText(props.row.status, '6084')}</span>;
          }
        },
        {
          title: '对账分类',
          dataIndex: 'verifyType',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('6086'),
          render: props => {
            return <span>{this.createDictText(props.row.verifyType, '6086')}</span>;
          }
        },
        {
          title: '对账单名称',
          dataIndex: 'verifyName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '整车款余额',
          dataIndex: 'vehicleAccountAmount',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '整车返利余额',
          dataIndex: 'vehicleRebateAmount',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '备件款余额',
          dataIndex: 'partAccountAmount',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '备件返利余额',
          dataIndex: 'partRebateAmount',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '建店保证金余额',
          dataIndex: 'depositAmount',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '其他类应收款项',
          dataIndex: 'otherInAmount',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '其他类应付款项',
          dataIndex: 'otherOutAmount',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '生成日期',
          dataIndex: 'createdAt',
          sorter: true,
          filter: true,
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '下发日期',
          dataIndex: 'issueDate',
          sorter: true,
          filter: true,
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '对账结果',
          dataIndex: 'verifyResult',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('6085'),
          render: props => {
            return <span>{this.createDictText(props.row.verifyResult, '6085')}</span>;
          }
        },
        {
          title: '驳回意见',
          dataIndex: 'checkDesc',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    }
  }
};
</script>
